﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ProgramacionRedes {
    public partial class FormConfiguracion : Form {
        private bool hay_cambios = false;

        public FormConfiguracion() {
            InitializeComponent();
            propertyGrid1.SelectedObject = ProgramacionRedes.Properties.Settings.Default;
            ProgramacionRedes.Properties.Settings.Default.SettingChanging += new System.Configuration.SettingChangingEventHandler(Default_SettingChanging);
        }

        void Default_SettingChanging(object sender, System.Configuration.SettingChangingEventArgs e) {
            hay_cambios = true;
        }

        private void FormConfiguracion_FormClosing(object sender, FormClosingEventArgs e) {
            if (hay_cambios) {
                DialogResult res = MessageBox.Show("¿Quiere guardar los cambios?", "¡Atención!", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                if (res == DialogResult.Yes) {
                    ProgramacionRedes.Properties.Settings.Default.Save();
                } else if (res == DialogResult.Cancel) {
                    e.Cancel = true;
                }
            }
        }
    }
}
